<div class="layui-fluid" id="VIEW-list-table" >
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">筛选数据</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space10 layui-form">
                        <form class="layui-form" lay-filter="searchForm">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">搜索条件</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="key" id="key" class="layui-input" placeholder="用户账户/用户操作"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4 btn-search">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <a class="layui-btn search_btn" onclick="logList.search()">搜索</a>
                                        <button type="reset" class="layui-btn layui-btn-primary search_btn" onclick="logList.reset()">重置</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <table id="logListId" lay-filter="logList"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var logList = {};
    var LogList = function (layui) {
        var admin = layui.admin, table = layui.table, form = layui.form, $ =layui.jquery;
        //初始化列表
        this.init = function () {
            form.render();
            admin.table({
                elem: '#logListId',
                api: 'pageLogList',
                height: 'full-200',
                formFilter:'searchForm',
                tableFilter:'logList',
                size:'sm',
                limit: 20,
                cols: [[
                    {title: 'ID', field: 'id', align:'center', width: 70},
                    {title: '用户账户', field: 'username', width: 120},
                    {title: '用户名', field: '', width: 120,
                        templet:function (d) {
                            if(d.user && d.user.realName){
                                return d.user.realName;
                            }else{
                                return "";
                            }
                        }},
                    {title: '用户操作', field: 'operation', width: 150},
                    {title: '请求参数', field: 'params'},
                    {title: 'ip地址', field: 'ip', width: 120},
                    {
                        field: 'createDate',
                        title: '操作时间',
                        align: 'center',
                        width: 150,
                        templet:function (d) {
                            if(d.createDate){
                                return '<p><span title="{{d.createDate}}" class="nepadmin-c-gray">'+d.createDate+'</span></p>';
                            }else{
                                return "";
                            }
                        }
                    }
                ]]
            });
        };
        //条件搜索
        this.search = function () {
            admin.tableSearch('searchForm','logListId',true);
        };
        //重置搜索条件
        this.reset = function () {
            $("#key").val("");
        };
    };
    //引入组件
    layui.use(['admin', 'table', 'form', 'jquery'], function () {
        logList = new LogList(layui);
        logList.init();
        var router = layui.router();
        console.log(router)
    });
</script>